package com.project.demo1;

/**
 * 封装路径结点类，字段包括：坐标、G 值、F 值、父结点，实现 Comparable 接口，方便优先队列排序
 */
public class Node  implements Comparable<Node>{

    public Cord cord; // 坐标
    public Node parent; // 父结点
    public int G; // G：是个准确的值，是起点到当前结点的代价
    public int H; // H：是个估值，当前结点到目的结点的估计代价

    public Node(int x, int y)
    {
        this.cord = new Cord(x, y);
    }

    public Node(Cord cord, Node parent, int g, int h)
    {
        this.cord = cord;
        this.parent = parent;
        G = g;
        H = h;
    }

    @Override
    public int compareTo(Node o)
    {
        if (o == null) return -1;
        if (G + H > o.G + o.H)
            return 1;
        else if (G + H < o.G + o.H) return -1;
        return 0;
    }

}
